<?php

class LightJob_Runner_Adapter_MockAdapter implements LightJob_Runner_IAdapter
{
	/**
	 * Blocking mode
	 *
	 * @var boolean
	 */
	private $block = false;
	
	/**
	 * Pool of actions
	 *
	 * @var array
	 */
	private $actions = array();
	
	public function countActions()
	{
		return count($this->actions);	
	}
	
	public function block()
	{
		$this->block = true;
	}
	
	public function release()
	{
		$this->block = false;
		$this->updateActions();
	}
	
	public function pushLogAction($txt,$file,$level='debug')
	{
	}
	
	public function pushMailAction($to,$from,$subject,$body)
	{
	}
	
	public function pushCmdAction($cmd)
	{
	}
	
	public function pushHttpGetAction($url,$headers=array())
	{
		return $this->actions[] = fopen(__FILE__,'r');
	}

	public function pushHttpPostAction($url,$params=array(),$headers=array())
	{
		return $this->actions[] = fopen(__FILE__,'r');
	}
	
	public function updateActions()
	{
		if($this->block) return;
		foreach($this->actions as $a) fclose($a);
		$this->actions = array();
	}
	
}